package com.zw;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

//发送方
@RunWith(SpringRunner.class)
@SpringBootTest(classes = MQ_Server.class)
public class Send {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Test
    public void testSend(){
        for (int i = 0; i < 20; i++) {
            if (i % 2 == 0){
                rabbitTemplate.convertAndSend(MQ_Config.EXCHANGE_TOPICS_INFORM,"user.emai","这条信息是给email " + i);
            } else {
                rabbitTemplate.convertAndSend(MQ_Config.EXCHANGE_TOPICS_INFORM,"user.sms","这条信息是给sms " + i);
            }
        }
    }

}